<template>
  <ul class="switches">
    <li class="switch-item" v-for="(item,index) in switches" :class="{'active':currentIndex === index}"
        @click="switchItem(index)">
      <span>{{item.name}} </span>
    </li>
  </ul>
</template>

<script type="text/ecmascript-6">
  export default {
    props: {
      switches: {
        type: Array,
        default: []
      },
      currentIndex: {
        type: Number,
        default: 0
      }
    },
    methods: {
      switchItem(index) {
        this.$emit('switch', index)
      }
    }
  }
</script>

<style scoped lang="scss" rel="stylesheet/css">
  @import "~common/scss/variable";

  .switches{
    display: flex;
    align-items: center;
    width: 225px;
    margin: 0 auto;
    .switch-item{
      flex: 1;
      text-align: center;
      font-size: $font-size-medium-x;
      color: $color-text-l;
      &.active{
        color: $color-sub-theme;
      }
      
    }
   
  }

</style>